package org.will.demo.events;

import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.MetricRegistry;
import org.reveno.atp.api.EventsManager;
import org.reveno.atp.api.Reveno;
import org.will.common.metric.TestCounter;
import org.will.cqrs.event.IEvent;
import org.will.ddd.eventing.DomainEvent;
import org.will.demo.view.MQDemoView;

import java.util.Date;

/**
 * Created by EdifierWill on 2016/8/8.
 */
public class MQDemoCreateEvent extends DomainEvent<Long> implements IEvent {

    public MQDemoCreateEvent(long id) {
        this.setAggregateRootId(id);
    }

    public void eventHandler(Reveno reveno,EventsManager.EventMetadata m) {
        if (!m.isRestore()) {
            MQDemoView mqDemoView = reveno.query().find(MQDemoView.class, this.getAggregateRootId());
            //System.out.println("MQDemoCreateEvent:" + mqDemoView._id + " " + mqDemoView._ename + " " + new Date().toString());
            //RestApiClient client = new RestApiClient();
            //client.create(mqDemoView);
            TestCounter.getInstance().Mark("CreateMQDemoComplete");
        }
    }
}
